<template>
	<view class="page">
		<view class="tabs">
			<view class="tab" :class="tabIndex===0?'active':''" @click="handleTab(0)">
				全部
			</view>
			<view class="tab" :class="tabIndex===1?'active':''" @click="handleTab(1)">
				已开具
			</view>
			<view class="tab" :class="tabIndex===2?'active':''" @click="handleTab(2)">
				待开具
			</view>
		</view>
		<view class="item-list" v-if="list.length>0">
			<view class="item" v-for="item in list" :key="item.id">
				<view class="item-row">
					<text class="item-lab">发票名称</text><text class="item-val">{{item.title}}</text>
				</view>
				<view class="item-row">
					<text class="item-lab">发票金额</text><text class="item-val">{{item.iprice}}元</text>
				</view>
				<view class="item-row">
					<text class="item-lab">发票状态</text><text class="item-val">{{item.istatus?'已开具':'待开具'}}</text>
				</view>
			</view>
		</view>
		<view class="empty-box" v-else>
			暂无数据！
		</view>
	</view>
</template>

<script>
	import {invoiceList} from '@/api/xiehui.js'
	export default{
		data(){
			return {
				tabIndex:0,
				query:{
					istatus:'',
					page:0,
					size:100,
				},
				list:[],
			}
		},
		onLoad(){
			this.getList();
		},
		methods:{
			getList(){
				invoiceList(this.query).then((res)=>{
					console.log(res);
					this.list=res.data.data.content;
				})
			},
			handleTab(index){
				this.tabIndex=index;
				if(index===0){
					this.query.istatus='';
				}else if(index===1){
					this.query.istatus=1;
				}else if(index===2){
					this.query.istatus=0;
				}
				this.getList();
			},
		}
	}
</script>

<style lang="scss">
	page{
		color: #333;
	}
	.empty-box {
		margin-top: 100rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #808080;
		font-size: 28rpx;
	}
	.tabs{
		height: 88rpx;
		line-height: 88rpx;
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 30rpx;
		.tab{
			position: relative;
			flex: 1;
			height: 100%;
			font-size: 28rpx;
			text-align: center;
		}
		.tab.active::after{
			position: absolute;
			left: 50%;
			transform: translateX(-50%);
			bottom: -5rpx;
			content: '';
			width: 58rpx;
			height: 10rpx;
			background: #0F7CFF;
			border-radius: 50rpx;
		}
	}
	.item-list{
		margin: 20rpx 30rpx;
		.item{
			margin-bottom: 20rpx;
			background: #fff;
			border-radius: 24rpx;
			padding: 32rpx;
			font-size: 30rpx;
			.item-row{
				padding: 20rpx;
			}
			.item-lab{
				color: #868D93;
				margin-right: 50rpx;
			}
		}
	}
</style>
